home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_100 / 113_01 / a15.h < prev    next >
Text File  |  1985-03-09  |  6KB  |  203 lines

  1. /*
  2.     HEADER:        CUG113;
  3.     TITLE:        1802 Cross-Assembler (BDS C Version);
  4.     FILENAME:    A15.H;
  5.     VERSION:    1.2;
  6.     DATE:        07/22/1985;
  7.  
  8.     DESCRIPTION:    "This program lets you use your CP/M-80-based computer
  9.             to assemble code for the RCA 1802, 1804, 1805, 1805A,
  10.             1806, AND 1806A microprocessors.  The program is
  11.             written in BDS C for the best possible performance on
  12.             8-bit machines.  All assembler features are supported
  13.             except relocation, linkage, listing control, and
  14.             macros.";
  15.  
  16.     KEYWORDS:    Software Development, Assemblers, Cross-Assemblers,
  17.             RCA, CDP1802, CDP1805A;
  18.  
  19.     SEE-ALSO:    CUG149, 1805A Cross-Assembler (Portable);
  20.  
  21.     SYSTEM:        CP/M-80;
  22.     COMPILERS:    BDS C;
  23.  
  24.     WARNINGS:    "This package is specifically tailored to CP/M-80
  25.             machines and the rather non-standard, but high-
  26.             performance BDS C compiler.  For other environments,
  27.             use the portable version of this package on CUG149.";
  28.  
  29.     AUTHORS:    William C. Colley III;
  30. */
  31.  
  32. /*
  33.     1805A Cross-Assembler  v 1.2
  34.  
  35.     Copyright (c) 1980, 82, 83, 85 William C. Colley, III.
  36.  
  37.     July 1982 -- Adapted from my 1802 cross assembler.  WCC3.
  38.  
  39.     Vers 1.0 -- March 1983 -- Added 1805A opcodes to the 1805 set.  WCC3.
  40.  
  41.     Vers 1.1 -- March 1983 -- Added CPU pseudo-op to combine 1802 and 1805A
  42.             cross-assemblers into a single program.  WCC3.
  43.  
  44.     Vers 1.2 -- June 1985 -- Fixed IF block nesting mechanism bug and bug
  45.             in 1805A SCAL opcode.  WCC3.
  46.  
  47. File:    a15.h
  48.  
  49. Global macro substitutions and external variable declarations.
  50. */
  51.  
  52. /*  For the benefit of the library's I/O drivers:  */
  53.  
  54. #include <bdscio.h>
  55.  
  56. /*  Set input line length:  */
  57.  
  58. #define    LINLEN    120
  59.  
  60. /*  Define symbol table parameters:  */
  61.  
  62. #define    SYMLEN    8    /*  Length of labels (must be an even number).    */
  63. #define    SYMBOLS    500    /*  Number of symbols in symbol table.        */
  64. #define    PADDING    "       "    /*  SYMLEN - 1 blanks.            */
  65.  
  66. /*  Number of if statements that can be nested:  */
  67.  
  68. #define    IFDEPTH    16
  69. #define    ON    1
  70. #define    OFF    -1
  71.  
  72. /*  BDOS functions called directly:  */
  73.  
  74. #define    GETDISK    25    /*  Get currently logged in disk.        */
  75.  
  76. /*  Define flag values:  */
  77.  
  78. #define    SKIP    TRUE    /*  Used with skip flag in getchr.        */
  79. #define    NOSKIP    FALSE
  80. #define    BIGST    TRUE    /*  Used to tell kind of string in getitem.    */
  81. #define    SMALST    FALSE
  82. #define    DEFEXT    FALSE    /*  Used to set default value of extend.    */
  83. #define    NOCODE    0    /*  Used to tell the hex generator what to do.    */
  84. #define    PUTCODE    1
  85. #define    FLUSH    2
  86. #define    NOMORE    3
  87.  
  88. /*  File descriptors:  */
  89.  
  90. #define    NOFILE    -1    /*  No file specified.                */
  91. #define    CONO    1    /*  Console output.                */
  92. #define    LST    2    /*  List device.                */
  93. #define    LODISK    4    /*  Lowest numbered disk.            */
  94.  
  95. /*  Items can have the following attributes:  */
  96.  
  97. #define    ALPHA    0    /*  Alphabetic character.            */
  98. #define    NUMERIC    1    /*  Numeric digit (0-9).            */
  99. #define    END_LIN    2    /*  End-of-Line marker (cr or ;).        */
  100. #define    COMMA    3    /*  Field separator (,).            */
  101. #define    OPERATR    4    /*  Operator (* - GE < ( SHR etc.).        */
  102. #define    QUOTE    5    /*  String delimiter (" ').            */
  103. #define    VALUE    6    /*  Evaluated expression.            */
  104. #define    BLANK    7    /*  White space (spc tab).            */
  105. #define    TRASH    8    /*  Other characters.                */
  106.  
  107. /*  Some tokens for composite operators:  */
  108.  
  109. #define    NO_OPR    0    /*  No operator.                */
  110. #define    GRTEQ    1    /*  Greater than or equal to.            */
  111. #define    NOTEQ    2    /*  Not equal to.                */
  112. #define    LESEQ    3    /*  Less than or equal to.            */
  113. #define    AND    4    /*  And.                    */
  114. #define    OR    5    /*  Or.                        */
  115. #define    XOR    6    /*  Exclusive or.                */
  116. #define    NOT    7    /*  1's complement.                */
  117. #define    MOD    8    /*  Mod--divide and return remainder.        */
  118. #define    SHL    9    /*  Shift left.                    */
  119. #define    SHR    10    /*  Shift right.                */
  120. #define    HIGH    11    /*  High byte of.                */
  121. #define    LOW    12    /*  Low byte of.                */
  122.  
  123. /*  Operator precedence values:  */
  124.  
  125. #define    UOP1    0    /*  Unary +, unary -.                */
  126. #define    MULT    1    /*  *, /, MOD, SHL, SHR.            */
  127. #define    ADDIT    2    /*  Binary +, binary -.                */
  128. #define    RELAT    3    /*  >, =, <, >=, <>, <=.            */
  129. #define    UOP2    4    /*  NOT.                    */
  130. #define    LOG1    5    /*  AND.                    */
  131. #define    LOG2    6    /*  OR, XOR.                    */
  132. #define    UOP3    7    /*  HIGH, LOW.                    */
  133. #define    RPREN    8    /*  ).                        */
  134. #define    LPREN    9    /*  (.                        */
  135. #define    ENDEX    10    /*  CR, ;, ,.                    */
  136. #define    START    11    /*  Start of expression.            */
  137.  
  138. /*  Bits of opcode attribute byte.  */
  139.  
  140. #define    PSOP    0x80    /*  Pseudo-op.                    */
  141. #define    IFGROUP    0x40    /*  Pseudo-op is IF, ELSE, ENDI.        */
  142. #define    XOPC    0x40    /*  Machine opcode is 2 bytes.            */
  143. #define    PROCNUM    0x38    /*  Mask to get processor number for opcode.    */
  144. #define    BYTES    0x07    /*  Mask to get number of bytes in opcode.    */
  145.  
  146. /*  Set up disk I/O buffers:  */
  147.  
  148. struct _buf _source, _list, _hex, *source, *list, *hex;
  149.  
  150. /*  Set up the symbol table: */
  151.  
  152. struct symbtbl
  153. {
  154.     char symname[SYMLEN];
  155.     unsigned symvalu;
  156. }
  157. symtbl[SYMBOLS], *symend, *sympoint;
  158.  
  159. /*  If stack and stack pointer.  */
  160.  
  161. char ifsp;
  162. int ifstack[IFDEPTH+1];
  163.  
  164. /*  Buffer to hold current line:  */
  165.  
  166. char *linptr, linbuf[LINLEN];
  167.  
  168. /*  Buffer to hold the code generated by a line.  */
  169.  
  170. char nbytes, binbuf[255];
  171.  
  172. /*  Buffers for the hex generator.  */
  173.  
  174. char chksum, hxbytes, *hxlnptr, hxlnbuf[44];
  175.  
  176. /*  Miscellanious mailboxes:  */
  177.  
  178. char errcode;        /*  Error records.                */
  179. int errcount;
  180. char evalerr;        /*  Flag to tell of error in eval.        */
  181. char backflg, oldattr;    /*  Item push-back buffer.            */
  182. unsigned oldvalu;
  183. char curdrive;        /*  Place to save drive that was current
  184.                     disk when assembly started.        */
  185. char hexflg;        /*  Flag for asmline to tell hex
  186.                 generator what to do.            */
  187. char directok;        /*  All symbols on line pre-defined.        */
  188. unsigned pc;        /*  Assembly program counter.            */
  189. unsigned address;    /*  Address to be put into listed line.        */
  190. char pass;        /*  Which pass the assembly is in.        */
  191. char extend;        /*  Flag to tell getopcod() whether the 1805A
  192.                 extended opcodes are allowed or not.    */
  193.  
  194. /*  Some trivial functions:  */
  195.  
  196. #define    backchr    linptr--        /*  Push back a character.    */
  197. , linbuf[LINLEN];
  198.  
  199. /*  Buffer to hold the code generated by a line.  */
  200.  
  201. char nbytes, binbuf[255];
  202.  
  203. /*  Buffers for the